﻿using System;
using System.Collections.Generic;
using System.Text;

namespace taigu.utils
{
    /// <summary>
    /// 系统内容处理类
    /// </summary>
   public static class ContentHelper
    {
        public static string GetPrefix(this string content,int num)
        {
            if (string.IsNullOrEmpty(content))
                return string.Empty;
            content = content.Length > num ? content.Left(num) : content;
            if(content.Contains("\n"))
            {
                return content.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
            }
            else
            {
                return content;
            }
        }

        public static string GetDateTime(this DateTime date)
        {
            return date.ToLongDateString();
        }
        public static string GetPrefixTest(string content, int num)
        {
            if (string.IsNullOrEmpty(content))
                return string.Empty;
            content = content.Length > num ? content.Left(num) : content;
            if (content.Contains("\n"))
            {
                return content.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
            }
            else
            {
                return content;
            }
        }
    }
}
